package com.lly.songhigh.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.lly.songhigh.R;
import com.lly.songhigh.fragment.FragmentFactory;

/**
 * Created by dllo on 15/10/20.
 */
public class MusicFragmentAdapter extends FragmentPagerAdapter {
    private int[] imageResId = {R.drawable.discover_selector, R.drawable.main_selector, R.drawable.recommend_selector};
    private Context context;

    public MusicFragmentAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return FragmentFactory.creatFragment(position);
    }

    @Override
    public int getCount() {
        return imageResId.length;
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_layout, null);
        ImageView img = (ImageView) view.findViewById(R.id.tab_item_img);
        img.setImageResource(imageResId[position]);
        return view;
    }
}
